/**
 * Copyright (c) 2002-2012 旭鸣信息
 * All rights reserved. 
 * File：UserCouponDaoImpl.java
 * History: Dec 27, 2012: Initially created, liuzhi.
 */
package com.xteam.ecsystem.dao.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xteam.ecsystem.dao.IUserCouponDao;
import com.xteam.ecsystem.entities.BaseMemeberCoupon;

/**
 * 用户购物券数据访问实现类
 * @author liuzhi
 *
 */
@Repository
public class UserCouponDaoImpl extends DDLPrefix implements IUserCouponDao {
	
	@SuppressWarnings("unchecked")
	@Autowired
	private BaseDaoImpl baseDao;

	public BaseMemeberCoupon getBmcInfo(String userId, String couponId) {
		try {
			String hql = SQL_FROM + BaseMemeberCoupon.REF + SQL_WHERE + "bmcMember=?" + SQL_AND + "bmcCoupon=?";
			Object obj = this.baseDao.findObject(hql, new Object[]{userId, couponId});
			
			if (obj != null) {
				return (BaseMemeberCoupon)obj;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}

	public void updateBmcInfo(BaseMemeberCoupon bmc) {
		try {
			this.baseDao.update(bmc);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void saveBmcInfo(BaseMemeberCoupon bmc){
		try {
			this.baseDao.save(bmc);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
